<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var indexGrid = null;
	var editAddChannelDialog = null;
	var updateChannelDialog = null;
	var deleteChannelDialog = null;
	var showChannelDialog=null;
	$(function(){
		indexGrid = $("#made_index_grid").ligerGrid({
				title : '活动首页',
                columns: [
                 { display: '频道名', name: 'name',isSort : false,
                  },
                  { display: 'mark', name: 'mark',isSort : false,
                  },
                { display: '创建时间', name: 'gmtCreated',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }}, 
                { display: '最后修改时间', name: 'gmtModified',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }
                },
                {
                	display: '<a href="javascript:;" onclick="addMadeChannel()">添加频道</a>', 
                	name: 'identifier',
                	isAllowHide: false, 
                	isSort : false,
					render: function (record, rowindex, value, column){
						//alert(value);
						var html = '<a onclick="addContent(\''+ value + '\')" href="javascript:;">添加内容</a>&nbsp;<a onclick="showChannel(\''+ value + '\')" href="javascript:;">详情</a>&nbsp;<a onclick="updateChannel(\''+ value + '\')" href="javascript:;">更新</a>&nbsp;<a onclick="deleteChannel(\''+ value + '\')" href="javascript:;">删除</a>'; 
						return html; 
					}
                }
                ], 
                pageSize:30,
                root :'list',
                record:'totalRecord',
                url: "/misc/index/indexGrid.htm?parent=${parent}", 
                width: '99%',height:'99%'
            });


	});
	//添加内容
	function addContent(channel){
		addContentDialog = $.ligerDialog.open({ height: 500,width:800, url: "/misc/index/addContent.htm?channel="+channel, isResize: false ,modal:true,title:'添加内容'});
	}
	//添加频道
	function addMadeChannel(){
		editAddChannelDialog = $.ligerDialog.open({ height: 200,width:400, url: "/misc/index/addChannel.htm?parent=${parent}", isResize: false ,modal:true,title:'添加频道'});
	
	}
	//更新频道
	function updateChannel(identifier){
		updateChannelDialog = $.ligerDialog.open({ height: 200,width:400, url: "/misc/index/updateChannelWeb.htm?identifier="+identifier, isResize: false ,modal:true,title:'更新频道'});
	
	}
	
	//删除频道
	function deleteChannel(identifier){
		$.post("/misc/index/deleteChannel.htm", {
			identifier :identifier
		},function(data){
			if(data=="success"){
				alert("已删除");
				indexGrid.loadData();
			}
			if(data=="error"){
				alert("删除失败了。");
			}
		});
	
	}
	//查看详情
	function showChannel(identifier){
		showChannelDialog = $.ligerDialog.open({ height: 600,width:800, url: "/misc/index/showChannel.htm?channel="+identifier, isResize: false ,modal:true,title:'查看频道详情'});
	}
	
	
</script>
<div id="made_index_grid" style="margin:0; padding:0"></div>